#include <stdio.h>
#include <windows.h>
#include "LibSV/sensor.h"

using namespace LibSV;

Movimiento mov = {0, 0, 0, 0};

int callback(void* ai_img, Movimiento* ai_mov)
{
	mov.pan += ai_mov->pan;
	mov.tilt += ai_mov->tilt;
	mov.rot += ai_mov->rot;
	mov.avance += ai_mov->avance;

	printf("\rPan: %i   \tTilt: %i   \tRotacion: %i   \tAvance: %i", 
		mov.pan, mov.tilt, mov.rot, mov.avance);

	return 0;
}

DWORD WINAPI funcThread(LPVOID lpParam)
{
	callbackFn cb = (callbackFn)lpParam;
	if (inicializar(1) == 0)
		activar(cb);

	return 0;
}

void main(void)
{
    printf("\n\t\t-[ Sensor Visual de movimiento ]-\n\n");

    HANDLE hThread = CreateThread( NULL, 0, funcThread, &callback, 0, NULL);  
    if (hThread == NULL)
        ExitProcess(-1);

    system("pause");
    detener();
    WaitForSingleObject(hThread, INFINITE);
    CloseHandle(hThread);
}